<extend name="Public/base"/>

<block name="body">

    <div class="main-title">
        <h2><present name="data">[ {$data.title} ] 子</present>文章列表 </h2>
    </div>

    <div class="cf">
        <a class="btn" href="{:U('updateInfo',array('a_type'=>'add'))}">新 增</a>
        <div class="search-form fr cf">
            <div class="sleft">
                <form action="__SELF__" method="post">
                    <input type="text" name="keyword" placeholder="请输入标题或内容">
                    <if condition="$_SESSION['groupid'] eq 1 or $_SESSION['groupid'] eq '' ">
                        <select name="area">
                        <option value="" >选择地区</option>
                            <volist name="areas" id="v">
                                <option value="{$v.areaID}" <if condition="$data.area_id eq $v['areaID']">selected</if>>{$v.area}</option>
                            </volist>
                        </select>
                    </if>
                    <input type="date" name="start">
                    <input type="date" name="end">
                    <input type="submit" name="">
                </form>
            </div>
        </div>
    </div>
    <div class="data-table table-striped">
            <table>
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>类型</th>
                        <th>标题</th>
                        <th>图片</th>
                        <th>创建时间</th>
                        <th>状态</th>
                        <th>区</th>
                        <th>退回原因</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
				<notempty name="list">
                <volist name="list" id="vo">
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.ttitle}</td>
                        <td>{$vo.title|msubstr=###,0,13,'utf-8',true}</td>
                        <td><img src="__ROOT__{$vo.tupian}" style="width:90px;height:90px;" /></td>
                        <td>{$vo.ctime|date='Y-m-d ',###}</td>
                        <td>
                            <if condition="$vo.status eq 0">
                                审核中
                            </if>
                            <if condition="$vo.status eq 1">
                                已通过
                            </if>
                            <if condition="$vo.status eq 2">
                                未通过
                            </if>
                        </td>
                        <td>{$vo.area}</td>
                        <td>
                            <php>$back = $vo['back']==''?"暂无":$vo['back']</php>
                            {$back}
                        </td>
                        <td>
                            <if condition="$_SESSION['groupid'] eq 1">
                                <if condition="$vo.status eq 1">
                                <div id="wrap" style=" display: none;width: 100%;">
                                    <form action="{:U('Admin/Police/changeState')}" class="a" method="post">
                                        <input type="text" name="back" value="" placeholder="请输入退回原因" />
                                        <input type="hidden" name="id" value="{$vo.id}" />
                                        <input type="submit" name="" value="提交" />
                                    </form>
                                </div>
                                    <a  class="back" onClick="aa(this)" title="退回" href="###">退回</a>
                                </if>
                                <if condition="$vo.status eq 2 or $vo.status eq 0 ">
                                    <a title="通过" href="{:U('Police/changeState',array('id'=>$vo['id'],'status'=>1))}">通过</a>
                                </if>
                            </if>
                            <a title="编辑" href="{:U('updateInfo',array('id'=>$vo['id'],'a_type'=>'edit'))}">编辑</a>
                            <a class="confirm ajax-get" title="删除" href="{:U('del?id='.$vo['id'])}">删除</a>
                        </td>
                    </tr>
                </volist>
				<else/>
				<td colspan="10" class="text-center"> aOh! 暂时还没有内容! </td>
				</notempty>
                </tbody>
            </table>
        <!-- 分页 -->
        <div class="page">
            {$_page}
        </div>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        function aa(obj) {
            $(obj).parent().children("#wrap").show();
        }
        $(function() {
            //搜索功能
            $("#search").click(function() {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //导航高亮
            highlight_subnav('{:U('index')}');
            //点击排序
        	$('.list_sort').click(function(){
        		var url = $(this).attr('url');
        		var ids = $('.ids:checked');
        		var param = '';
        		if(ids.length > 0){
        			var str = new Array();
        			ids.each(function(){
        				str.push($(this).val());
        			});
        			param = str.join(',');
        		}
        		if(url != undefined && url != ''){
        			window.location.href = url + '/ids/' + param;
        		}
        	});
        });
    </script>
</block>